package com.pxmeta.dynamic.mapper;

import com.baidubce.services.iotdm.model.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pxmeta.dynamic.entity.Dynamic;
import com.pxmeta.dynamic.entity.dto.DynamicDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 社区内容Mapper接口
 *
 * @author wcl
 * @date 2022-03-21
 */
public interface DynamicMapper extends BaseMapper<Dynamic> {

    List<DynamicDTO> getByTopicId(@Param("topicId") Long topicId,@Param("userId") Long userId, @Param("page") IPage page, @Param("type") Integer type, @Param("isCircleUser") Boolean isCircleUser);
    List<DynamicDTO> getByCircleId(@Param("circleId") Long circleId,@Param("userId") Long userId, @Param("page") IPage page, @Param("type") Integer type, @Param("circleType") Integer circleType, @Param("nearUserIds") List<Long> nearUserIds);
    List<DynamicDTO> search(@Param("circleId") Long circleId,@Param("userId") Long userId, @Param("page") IPage page, @Param("keyword") String keyword);

    @Select("SELECT a.id from (SELECT count(1) as total, dynamic_id as id from kt_community_content cc left join kt_community_dynamic_user_like ul on cc.id = ul.dynamic_id where cc.circle_id = #{circleId} and cc.is_del = 0 and ul.is_del =0 GROUP BY cc.id order by total desc limit 1) a")
    Long getHotDynamicId(@Param("circleId") Long circleId);

    IPage<DynamicDTO> getList( @Param("page") IPage page, @Param("status") Integer status);

    void deleteById(@Param("id") Long id);


    List<Dynamic> getRecommendUserDynamic(@Param("userIds") List<Long> userIds);
}
